Skip to content

Clean up domain modeling and service logic#39

Merged
jeyongsong merged 9 commits intomainfrom
refactor-code
Mar 17, 2026
Merged

Clean up domain modeling and service logic#39
jeyongsong merged 9 commits intomainfrom
refactor-code

Conversation

@jeyongsong
Copy link
Member

This pull request introduces a major refactor around payday handling and daily work status logic, shifting payday from a simple integer to a dedicated value object (PaydayDay). It also adds richer event and status resolution for daily work schedules, and reorganizes notification-related entities into their own package. The changes improve type safety, encapsulation, and extensibility for future event types.

Payday and daily event logic refactor:

  • Introduced the PaydayDay value object to encapsulate payday logic, including effective payday calculation and weekend adjustment. All references to payday in entities and repositories now use PaydayDay instead of Int. (src/main/kotlin/com/moa/entity/PaydayDay.kt, src/main/kotlin/com/moa/entity/Profile.kt, src/main/kotlin/com/moa/repository/ProfileRepository.kt, [1] [2] [3]
  • Removed the legacy payday resolver function and replaced its usage with methods on PaydayDay. (src/main/kotlin/com/moa/service/PaydayResolver.kt, src/main/kotlin/com/moa/service/PaydayResolver.ktL1-L17)
  • Updated profile update and onboarding logic to use the new PaydayDay object, including validation and conversion for API responses. (src/main/kotlin/com/moa/service/ProfileService.kt, [1] [2] [3] [4] [5]

Daily work status and event resolution:

  • Added DailyWorkStatusType.resolve and DailyEventType.resolve static methods to encapsulate business logic for determining work status and daily events, improving extensibility for future event types. (src/main/kotlin/com/moa/entity/DailyWorkStatusType.kt, src/main/kotlin/com/moa/entity/DailyEventType.kt, [1] [2]
  • Refactored WorkdayService to use the new resolution methods for work status and events, replacing previous ad-hoc logic. (src/main/kotlin/com/moa/service/WorkdayService.kt, [1] [2] [3] [4]

Notification entity reorganization:

  • Moved notification-related entities and enums into a dedicated notification package, updating imports and repository usage accordingly for better modularity. (src/main/kotlin/com/moa/entity/notification/NotificationLog.kt, src/main/kotlin/com/moa/entity/notification/NotificationSetting.kt, src/main/kotlin/com/moa/entity/notification/NotificationSettingType.kt, src/main/kotlin/com/moa/entity/notification/NotificationStatus.kt, src/main/kotlin/com/moa/entity/notification/NotificationType.kt, src/main/kotlin/com/moa/repository/NotificationLogRepository.kt, src/main/kotlin/com/moa/repository/NotificationSettingRepository.kt, [1] [2] [3] [4] [5] [6] [7]

Other improvements:

  • Moved SalaryInputType enum to its own file for clarity and maintainability. (src/main/kotlin/com/moa/entity/SalaryInputType.kt, [1] [2]
  • Refactored salary calculation logic in WorkdayService to use dependency injection for SalaryCalculator instead of static methods. (src/main/kotlin/com/moa/service/WorkdayService.kt, [1] [2] [3]

These changes collectively improve the maintainability and extensibility of payday, daily event, and notification logic throughout the codebase.

Copilot AI review requested due to automatic review settings March 17, 2026 17:08
@github-actions
Copy link

github-actions bot commented Mar 17, 2026

Test Results

49 tests   49 ✅  0s ⏱️
 7 suites   0 💤
 7 files     0 ❌

Results for commit 65f167a.

♻️ This comment has been updated with latest results.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Major domain/service refactor to improve type-safety and encapsulation around payday handling, daily work status/event resolution, salary calculations, and notification entity organization.

Changes:

  • Introduces PaydayDay (@Embeddable) value object and migrates payday usage from IntPaydayDay.
  • Adds centralized resolution logic via DailyWorkStatusType.resolve(...) and DailyEventType.resolve(...), refactoring WorkdayService to use them.
  • Moves notification entities into com.moa.entity.notification and refactors salary/earnings calculation into injectable calculator services.

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/main/resources/application-prod.yml Changes prod Hibernate DDL behavior (updatevalidate).
src/main/kotlin/com/moa/entity/PaydayDay.kt Adds payday value object with effective-date/weekend adjustment logic.
src/main/kotlin/com/moa/entity/Profile.kt Replaces paydayDay: Int with embedded PaydayDay.
src/main/kotlin/com/moa/repository/ProfileRepository.kt Updates payday query method to accept PaydayDay.
src/main/kotlin/com/moa/service/ProfileService.kt Updates payday update/response mapping for PaydayDay.
src/main/kotlin/com/moa/service/OnboardingStatusService.kt Updates onboarding response mapping for PaydayDay.
src/main/kotlin/com/moa/service/PaydayResolver.kt Removes legacy payday resolver function.
src/main/kotlin/com/moa/entity/DailyWorkStatusType.kt Adds resolve(...) to centralize daily status logic.
src/main/kotlin/com/moa/entity/DailyEventType.kt Adds resolve(...) to centralize daily event resolution (payday).
src/main/kotlin/com/moa/service/WorkdayService.kt Refactors to use new resolution methods and injected calculators.
src/main/kotlin/com/moa/service/calculator/SalaryCalculator.kt Moves calculator to service package and converts from static object → Spring bean.
src/main/kotlin/com/moa/service/calculator/EarningsCalculator.kt Moves to service package and injects SalaryCalculator.
src/main/kotlin/com/moa/service/notification/PaydayNotificationBatchService.kt Refactors payday profile lookup to use PaydayDay.resolvingTo(...).
src/main/kotlin/com/moa/service/notification/NotificationMessageBuilder.kt Updates imports to new notification/calculator packages.
src/main/kotlin/com/moa/service/notification/NotificationDispatchService.kt Updates imports to moved notification entities.
src/main/kotlin/com/moa/service/notification/NotificationSyncService.kt Updates imports to moved notification entities.
src/main/kotlin/com/moa/service/notification/NotificationSettingService.kt Updates imports to moved notification entities.
src/main/kotlin/com/moa/service/notification/NotificationBatchService.kt Updates imports for moved notification entities.
src/main/kotlin/com/moa/service/dto/NotificationSettingUpdateRequest.kt Updates DTO import to moved NotificationSettingType.
src/main/kotlin/com/moa/service/dto/NotificationSettingResponse.kt Updates DTO imports to moved notification entities.
src/main/kotlin/com/moa/repository/NotificationLogRepository.kt Updates imports to moved notification entities.
src/main/kotlin/com/moa/repository/NotificationSettingRepository.kt Updates imports to moved notification entities.
src/main/kotlin/com/moa/entity/notification/NotificationType.kt Moves enum to com.moa.entity.notification.
src/main/kotlin/com/moa/entity/notification/NotificationStatus.kt Moves enum to com.moa.entity.notification.
src/main/kotlin/com/moa/entity/notification/NotificationSettingType.kt Moves enum to com.moa.entity.notification.
src/main/kotlin/com/moa/entity/notification/NotificationSetting.kt Moves entity to com.moa.entity.notification.
src/main/kotlin/com/moa/entity/notification/NotificationLog.kt Moves entity to com.moa.entity.notification.
src/main/kotlin/com/moa/entity/SalaryInputType.kt Extracts SalaryInputType into its own file.
src/main/kotlin/com/moa/entity/PayrollVersion.kt Removes nested SalaryInputType enum from this file.
src/test/kotlin/com/moa/entity/PaydayDayTest.kt Adds unit tests for PaydayDay rules and effective-date logic.
src/test/kotlin/com/moa/entity/DailyWorkStatusTypeTest.kt Adds unit tests for daily status resolution.
src/test/kotlin/com/moa/entity/DailyEventTypeTest.kt Adds unit tests for daily event resolution (payday).
src/test/kotlin/com/moa/service/calculator/SalaryCalculatorTest.kt Updates tests for new package/instance-based SalaryCalculator.
src/test/kotlin/com/moa/service/calculator/EarningsCalculatorTest.kt Updates constructor usage to inject SalaryCalculator.
src/test/kotlin/com/moa/learning/fcm/FcmSendLearningTest.kt Fixes test package declaration to match directory.
Comments suppressed due to low confidence (1)

src/main/kotlin/com/moa/service/notification/PaydayNotificationBatchService.kt:63

  • candidatePaydayDays is computed as a Set<PaydayDay> and passed into ProfileRepository.findAllByPaydayDayIn(...). If the repository method is changed to query on the embedded scalar (e.g., paydayDay.value) for JPQL/provider compatibility, this call site should pass the corresponding Int values instead of embeddables to keep the batch query reliable.
    private fun findPaydayProfiles(date: LocalDate): List<Profile> {
        val candidatePaydayDays = PaydayDay.resolvingTo(date)

        if (candidatePaydayDays.isEmpty()) {
            return emptyList()
        }

        return profileRepository.findAllByPaydayDayIn(candidatePaydayDays)
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@jeyongsong jeyongsong merged commit 0b4dcdd into main Mar 17, 2026
3 checks passed
@jeyongsong jeyongsong deleted the refactor-code branch March 17, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants